package com.kiseny.dao;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.kiseny.po.Link;
import com.kiseny.po.LinkType;

public class LinkDAO extends BaseDAO<Link> {
	
	@SuppressWarnings("unchecked")
	public List<Link> findByLinkType(LinkType linkType) {
        List<Link> linkList = null;
        
        DetachedCriteria criteria = DetachedCriteria.forClass(Link.class);
        criteria.add(Restrictions.eq("deleteFlag", new Boolean(false)));
        
        criteria.add(Restrictions.eq("linkType", linkType));
        try {
        	linkList = (List<Link>) getHibernateTemplate().findByCriteria(criteria);

        } catch (RuntimeException e) {
            getLogger().error("Fail to execute it.", e);
            throw e;
        }
        
        return linkList;
	}
    
}
